<template>
	<view class="reset_password_warp">
		<Header left-path-type="navigateTo" :leftPath="leftPath" :title="$t('common.reset.password')"/>
		<view class="reset_password_content_warp">
			<view class="_content_item">
				<view class="_content_item_title">{{$t('common.email')}}</view>
				<up-input
				    :placeholder="$t('common.email.placeholder')"
				    border="surround"
				    v-model="form.email"
					:customStyle="inputCss"
				  ></up-input>
			</view>
			<view class="_content_item">
				<view class="_content_item_title">{{$t('common.verification.code')}}</view>
				<InputCodeComm @getCode="getEmailCode" :codeNumberRef="form.email" :type="SMS_TYPE.PASSWD"/>
				<view class="email-msg-warp">{{$t('common.email.msg')}}</view>
			</view>
			<view class="but_comm_warp" @click="resetPasswordOk">
				<text style="margin-left: 10rpx;">{{$t('common.next.step')}}</text>
			</view>
		</view>
		<up-toast ref="uToastRef"></up-toast>
	</view>
</template>

<script>
	import Header from '@/components/header_comm2.vue';
	import InputEmailComm from '@/components/input-email-comm.vue';
	import InputCodeComm from '@/components/input-code-comm.vue';
	import { SMS_TYPE } from '@/utils/enumUtils.js';
	
	export default {
		components:{Header,InputEmailComm,InputCodeComm},
		data() {
			return {
				inputCss:{
					"height":'80rpx',
					"background": "#F3F3F3FF",
					"border-radius": "20rpx",
					"border": "0rpx",
					"padding-left": "16px",
				},
				form:{
					email:null,
					code:null,
				},
				startCountdown:false,// 清空倒计时
				leftPath:"/pages/login/login",
			};
		},
		computed: {
		   SMS_TYPE() {
		     return SMS_TYPE;
		   }
		},
		onLoad(option) {
			const back = option.back;
			if(back === "login"){
				this.leftPath = "/pages/login/login"
			}else if(back === "editLogin"){
				this.leftPath = "/pages/edit_login_password/edit_login_password"
			}
		},
		mounted() {
		},
		methods: {
			// 获取邮箱验证码
			getEmailCode(code){
				if(code){
					this.form.code = code;
				}
			},
			// 下一步
			resetPasswordOk(){
				const form = this.form;
				if(!form.email){
					this.$refs.uToastRef.show({
						type: 'error',
						message: this.$t('common.verification.code.placeholder2'),
					});
				}
				if(!form.code){
					this.$refs.uToastRef.show({
						type: 'error',
						message: this.$t('common.verification.code.placeholder'),
					});
				}
				uni.redirectTo({
					url: '/pages/reset_password2/reset_password2?email='+form.email+"&code="+form.code
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.reset_password_warp{
	height: calc(100vh - 0rpx);
	overflow: auto;
	.reset_password_content_warp{
		padding: 50rpx;
	}
	._content_item{
		margin-bottom: 40rpx;
		._content_item_title{
			font-weight: 500;
			font-size: 28rpx;
			color: #333333;
			margin-bottom: 20rpx;
		}
	}
	.but_comm_warp{
		margin-top: 60rpx;
	}
}
</style>
